package com.ruoyi.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.admin.domain.ZhxNote;
import com.ruoyi.admin.service.IZhxNoteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 互动信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-11
 */
@RestController
@RequestMapping("/ZhxAdmin/ZhxNote")
public class ZhxNoteController extends BaseController
{
    @Autowired
    private IZhxNoteService zhxNoteService;

    /**
     * 查询互动信息列表
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxNote:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhxNote zhxNote)
    {
        startPage();
        List<ZhxNote> list = zhxNoteService.selectZhxNoteList(zhxNote);
        return getDataTable(list);
    }

    /**
     * 导出互动信息列表
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxNote:export')")
    @Log(title = "互动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhxNote zhxNote)
    {
        List<ZhxNote> list = zhxNoteService.selectZhxNoteList(zhxNote);
        ExcelUtil<ZhxNote> util = new ExcelUtil<ZhxNote>(ZhxNote.class);
        util.exportExcel(response, list, "互动信息数据");
    }

    /**
     * 获取互动信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxNote:query')")
    @GetMapping(value = "/{noteId}")
    public AjaxResult getInfo(@PathVariable("noteId") Long noteId)
    {
        return success(zhxNoteService.selectZhxNoteByNoteId(noteId));
    }

    /**
     * 新增互动信息
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxNote:add')")
    @Log(title = "互动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhxNote zhxNote)
    {
        return toAjax(zhxNoteService.insertZhxNote(zhxNote));
    }

    /**
     * 修改互动信息
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxNote:edit')")
    @Log(title = "互动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhxNote zhxNote)
    {
        return toAjax(zhxNoteService.updateZhxNote(zhxNote));
    }

    /**
     * 删除互动信息
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxNote:remove')")
    @Log(title = "互动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noteIds}")
    public AjaxResult remove(@PathVariable Long[] noteIds)
    {
        return toAjax(zhxNoteService.deleteZhxNoteByNoteIds(noteIds));
    }
}
